from django.db import models
from jrcmodel.models import MyConstants, CST

class UploadFile(models.Model):
    status_id = models.IntegerField(choices = MyConstants.STATUS_CHOICES)
    
    # Original file name
    original_name = models.CharField(max_length = 128, blank = True)
    
    import_file = models.FileField(upload_to = "%Y/%m")
    
    # Each file should be linked w/ CST
    cst_id = models.ForeignKey(CST)
    
    created_at = models.DateTimeField(auto_now_add = True)
    updated_at = models.DateTimeField(auto_now = True)
    
    def file_url(self):
        return self.get_import_file_size()
    
    def __unicode__(self):
        return "%d %s (%s)" % (self.pk, self.original_name, self.import_file.name)
    